import React, { Component } from 'react'
import {View} from 'react-native'
import {WebView} from 'react-native-webview'
import * as Location from 'expo-location'


interface Props {
  
}
interface State {
  
}

export default class Map extends Component<Props, State> {
  state = {
    location:'',
    errorMsg:''
  }

  getLocation(){
    (async () => {
      let { status } = await Location.requestPermissionsAsync();
      if (status !== 'granted') {
        this.setState({
          errorMsg:'Permission to access location was denied'
        })
      }

      let location = await Location.getCurrentPositionAsync({});
      this.setState({
        location
      })
      console.log('location:',location)
    })();
  }

  componentDidMount(){
    this.getLocation()
  }

  render() {
    return (
      <View style={{width:'100%',flex:1}}>
        
        <WebView source={{uri:"https://map.baidu.com/search/%E9%A4%90%E9%A6%86/@12950195.41211343,4841718.5,16z?querytype=nb&ar=(12949195.41211343,4840718.5;12951195.41211343,4842718.5)&wd=%E9%A4%90%E9%A6%86&c=131&bdtp=0&nb_x=12950195.41211343&nb_y=4841718.5&userSign=0&b=(12948069.41211343,4840282.5;12952321.41211343,4843154.5)&l=16&pn=0&uid=53cebd509c9daa612a02e16f&r=1000&from=webmap&device_ratio=2&da_src=shareurl"}}>

        </WebView>
      </View>
    )
  }
}
